
package de.stoneageracer.vehicles;

import com.jme3.scene.Spatial;

/**
 *
 * @author Basti
 */

/**
 * a Weapon to add to the Car
 * @author Basti
 */
public abstract class Weapon extends VehiclePart{
    
    /**
     * the actual recharge value of the weapon
     */
    public float recharge=99;
    
    /**
     * the maximal recharge value needed to fire the weapon
     */
    public float maxRecharge;
    
    public int loads;
    
    /**
     * Creates a Weapon to be added as VehiclePart to the Car
     * @param name a String containing the name of the Weapon
     * @param spatial the mesh of the weapon
     * @param weight a weight
     * @param rechargeTime the maximal rechargeTime needed to fire the weapon
     * @param loads a value how many loads the weapon has (-1 for endless loads)
     */
    public Weapon(String name, Spatial spatial, float weight, float rechargeTime, int loads){
        super(name,spatial,weight);
        maxRecharge = rechargeTime;
        this.loads = loads;
    }
    
    /**
     * the Method executed when firing the weapon
     */
    public abstract void onAction();
    
    /**
     * a method to get the actual recharge value in percentage
     * @return a double containing the recharge value in percentage (100% = you can fire)
     */
    public double getRecharge(){
        return 100.0*(recharge/maxRecharge);
    }
}
